//
//  IconButton.m
//  AffectionBee
//
//  Created by 李通 on 16/8/20.
//  Copyright © 2016年 chivalrous. All rights reserved.
//

#import "IconButton.h"

@interface IconButton ()

@end


@implementation IconButton

//封装iconButton创建方法
- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        CGFloat margin = frame.size.height - frame.size.width;
        CGFloat w = frame.size.width;
        //在UIButton中有三个对EdgeInsets的设置：ContentEdgeInsets、titleEdgeInsets、imageEdgeInsets
        self.imageEdgeInsets = UIEdgeInsetsMake(0, 0, margin, 0);//调整图片大小和位置
        
        self.titleLabel.font = [UIFont systemFontOfSize:13];//title字体大小
        self.titleLabel.textAlignment = NSTextAlignmentCenter;//设置title的字体居中
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];//设置title字体颜色
        self.titleEdgeInsets = UIEdgeInsetsMake(w, -w, margin, 0);//调整title位置
    }
    
    return self;
}

@end
